﻿
namespace Leetcode.N5234;
public class Solution
{
    public IList<string> RemoveAnagrams(string[] words)
    {
        var ans = new List<string>();
        var pre = words[0].ToArray().OrderBy(_ => _).ToArray();
        ans.Add(words[0]);

        for (int i = 1; i < words.Length; i++)
        {
            var cur = words[i].ToArray().OrderBy(_ => _).ToArray();

            if (this.Equal(cur, pre))
            {
                continue;
            }

            pre = cur;
            ans.Add(words[i]);
        }
        return ans;
    }
    private bool Equal(char[] v1, char[] v2)
    {
        if (v1.Length != v2.Length)
        {
            return false;
        }
        for (int i = 0; i < v1.Length; i++)
        {
            if (v1[i] != v2[i])
            {
                return false;
            }
        }
        return true;
    }
}